package com.mgface.thymeleaf.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import com.mgface.thymeleaf.util.SwissKnife;

/**
 * 做一些公共操作的类
 * 
 * @author yuxiang
 *
 */
public class AssignCommonInterceptor extends HandlerInterceptorAdapter {
	
	/**
	 * 在业务处理器处理请求、执行完成后,生成视图之前执行的动作<br/>
	 */
	@Override
	public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,ModelAndView modelAndView) throws Exception {
		if(modelAndView!=null){
			String basePath = SwissKnife.getBasePath(request, response);
			modelAndView.addObject("context", basePath);
		}
	}
}
